#!/bin/bash
echo "开始清洗客户基表，抽数到dw层"
hive -v -e "set hive.exec.mode.local.auto=true; \
insert overwrite table dw02.dw_cust_info
select 
        cust_id,
        regexp_replace(cust_name,'[^一-龥]+','') cust_name,
        org_id,
        code_id,
        amt,
        dt,
        regexp_replace(phone,'[^0-9]+','') phone,
        acctno,
        yg_no,
        current_timestamp etl_time
    from ods02.rdbms_cust_info;"
echo $?
echo "验证数据**************************"
c=`hive -e "set hive.exec.mode.local.auto=true;select count(1) from dw02.dw_cust_info"`
echo "dw层的数据量为:${c}条"
c1=`hive -e "set hive.exec.mode.local.auto=true;select count(1) from ods02.rdbms_cust_info"`
echo "ods层的数据量为:${c1}条"
if [ "$c" == "$c1" ];then
    echo "数据一致，清洗成功"
else
    echo  "抽数失败"
fi